//
//  UppayWindow.m
//  BUS365
//
//  Created by login on 15-7-9.
//
//

#import "UppayWindow.h"
@implementation UppayWindow

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self.windowLevel = UIWindowLevelNormal + 1;
        // 这里，不能设置UIWindow的alpha属性，会影响里面的子view的透明度，这里我们用一张透明的图片
        // 设置背影半透明
    }
    
    return self;
}
-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
    UIView *hitView = (UIView *)[super hitTest:point withEvent:event];
    if ([hitView isKindOfClass:[UIWindow class]])
    {
        return nil;
    }
    else
    {
        return hitView;
    }
}
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
    return YES;
}


- (void)show {
    [self makeKeyAndVisible];
}

- (void)hide
{
    [UIView animateWithDuration:0.5 animations:^{
        
        self.alpha = 0;
//        [self setHidden:YES];

    }];
//    [self setHidden:YES];
    
//    CGRect rect = [UIScreen mainScreen].bounds;
//    
//    [UIView animateWithDuration:0.5 animations:^{
//        self.frame = CGRectMake(0, rect.size.height, rect.size.width, rect.size.height);
//    }];

    
}

- (void)alertUp:(CGFloat)height
{
    [self makeKeyAndVisible];
    [UIView animateWithDuration:0.5 animations:^{
        self.frame = CGRectMake(0, [UIScreen mainScreen].bounds.size.height - height,[UIScreen mainScreen].bounds.size.width , height);
    }];

}

- (void)alertDown:(CGFloat)height
{
    [UIView animateWithDuration:0.5 animations:^{
        self.frame = CGRectMake(0, [UIScreen mainScreen].bounds.size.height,[UIScreen mainScreen].bounds.size.width , height);
        
    } completion:^(BOOL finished) {
//        [self dismiss];
        [self resignKeyWindow];
        
    }];


}

- (void)dismiss {
    [self resignKeyWindow];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
